package 单例模式;

public class 双重校验锁 {
    private volatile static 双重校验锁 singleton;  //对象锁

    private  双重校验锁() {
    }

    public static 双重校验锁 getSingleton(){
        synchronized (双重校验锁.class){ //方法锁
            if (singleton == null){
                singleton = new 双重校验锁();
            }
        }
        return singleton;
    }
}
